# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 18:08:47 2020

@author: wjx
"""

menu = {
    '北京':{'海淀':{'a':{},'b':{},'c':{}},'朝阳':{'d':{},'e':{},'f':{}}},
    '上海':{'黄浦':{'g':{},'h':{}},'松江':{'o':{},'p':{}}}
}

def menu_func(menu):
    while True:
        for key in menu:
            print(key)
        inp = input('>>>').strip()
        if inp.upper() == 'Q': return 'q'
        if inp.upper() == 'B': return 'b'
        elif menu.get(inp):
            flag = menu_func(menu[inp])
            if flag == 'q': return 'q'


def menu_xunhuan():
    lst = [menu]
    while lst:
        for key in lst[-1]:
            print(key)
        inp = input('>>>')
        if inp.upper() == 'Q': break
        elif inp.upper() == 'B':lst.pop()
        elif lst[-1].get(inp):
            lst.append(lst[-1][inp])